using System;
using System.Collections.Generic;
using System.Text;
using ctem.kernel;
using ctem.kernel.lib;
using System.Windows.Forms;
using System.Threading;
using MCSharp;
using System.Runtime.Serialization;
using System.Runtime.Remoting.Messaging;

namespace    ctem.samples.actors.concurrent
{
 using System;
using MCSharp;
using System.Threading;
using System.Runtime.Serialization;
using System.Runtime.Remoting.Messaging;

[Serializable()]
public  partial class Bode:Actor, ISerializable {

 //-------------- MCsharp functions -----------

 public Bode ( ) {
  mcsharp_initiate();
}

 public Bode ( SerializationInfo info, StreamingContext context ) {
  MCSharp.Serialization.UnPack ( info, context, this );
   }

 public void GetObjectData ( SerializationInfo info, StreamingContext context ) {
  MCSharp.Serialization.Pack ( info, context, this );
 }

 public void mcsharp_initiate ( ) {

  Monitor.Enter ( CommExec.Objects );
  int mcObjectNumber = CommExec.Objects.Count + 1;
  CommExec.Objects.Add ( mcObjectNumber, this );
  Monitor.Exit ( CommExec.Objects );

 }

  private class McsharpPrivateClassStartingUIThread {

   Bode parent;

   public McsharpPrivateClassStartingUIThread ( Bode parent
              ) {
    this.parent = parent;
   }

   public void run() {

   MCSharp.ThreadManager.SetThreadAffinityMask();

    parent.mcsharpStartingUIThreadBody (  );

   }
  }

  private void mcsharpStartingUIThreadBody (

              )
 {
   Application.Run( form  )  ;
 }




   void StartingUIThread (  ) {
   McsharpPrivateClassStartingUIThread prclassobject = new McsharpPrivateClassStartingUIThread ( this );
   ThreadStart tstart = new ThreadStart ( prclassobject.run );
   ( new Thread ( tstart ) ).Start();
  }
}


}